



//
//  NFeedbackCell.m
//  nncloud
//
//  Created by macfai on 2018/9/20.
//  Copyright © 2018年 youedata. All rights reserved.
//

#import "NFeedbackCell.h"

@interface NFeedbackCell()



@end

@implementation NFeedbackCell

-(void)setFlag:(NSString *)flag{
    _flag = flag;
    if ([flag isEqualToString:@"fee"]) {
        self.stateLabel.hidden = false;
    }
}

-(void)setIndustryBaobiaoModel:(NIndustyBaobiaoModel *)industryBaobiaoModel{
    _industryBaobiaoModel = industryBaobiaoModel;
    self.nameLabel.text = industryBaobiaoModel.industryName;
    self.timeLabel.text = industryBaobiaoModel.industryYear;
    //0待提交   1待审核  2已审核
   NSInteger status =  [industryBaobiaoModel.industryStatus integerValue];
    if (status==0) {
        self.stateLabel.text = @"待提交";
    }else if (status==1){
         self.stateLabel.text = @"待审核";
    }else if(status==2){
         self.stateLabel.text = @"已审核";
    }
    else{
        self.stateLabel.text = @"已反审";
    }
    
}

-(void)setCaiwuBaobiaoModel:(NIndustyBaobiaoModel *)caiwuBaobiaoModel{
    _caiwuBaobiaoModel = caiwuBaobiaoModel;
    self.nameLabel.text = caiwuBaobiaoModel.financeName;
    self.timeLabel.text = caiwuBaobiaoModel.financeYear;
//    if ([caiwuBaobiaoModel.financeStatus isEqualToString:@"0"]) {
//        self.stateLabel.text = @"待审核";
//    }
    NSInteger status =  [caiwuBaobiaoModel.financeStatus integerValue];
    if (status==0) {
        self.stateLabel.text = @"待提交";
    }else if (status==1){
        self.stateLabel.text = @"待审核";
    }else if(status==2){
        self.stateLabel.text = @"已审核";
    }else{
        self.stateLabel.text = @"已反审";
    }
}

//set方法在xib页面中有可能不管用

-(void)setModel:(NFeedbackModel *)model{
    
//    model = _model;
//    self.nameLabel.text = model.questionTitle;
//    self.timeLabel.text = model.questionCreateTime;
//    self.tipLabel.text = model.questionType;
//    self.stateLabel.text = model.questionProgress;
    
}


-(void)configWithData:(NFeedbackModel *)model{
    
    self.nameLabel.text = model.questionTitle;
    self.timeLabel.text = [self timeTransfer:model.questionCreateTime];
    [self configCellWith:model.questionType];
    [self configProgressWith:model.questionProgress];
//    self.tipLabel.text = model.questionType;
//    self.stateLabel.text = model.questionProgress;
}

- (UIColor *)getProgressColorWithProgress:(NSString *)progress
{
    switch ([progress integerValue]) {
        case 0:
        case 1:
        case 5:
        case 6:
        {
            return NColorFrom16RGB(0xf97c14);
        }
            break;
        case 2:
        case 7:
        {
            return NColorFrom16RGB(0x5da7ff);
        }
            break;
        case 3:
        case 4:
        {
            return NColorFrom16RGB(0x49cc93);
        }
            break;
        case 8:
        {
            return NColorFrom16RGB(0x666666);
        }
            break;
        case 9:
        case 10:
        {
            return NColorFrom16RGB(0xeb2222);
        }
            break;
            
        default:
        {
            return [UIColor darkGrayColor];
        }
            break;
    }
    //    return [UIColor redColor];
}

//问题进度
- (void)configProgressWith:(NSString *)progress{
    
    NSInteger page = [progress integerValue];
    
    switch (page) {
        case 0:
        {
            self.stateLabel.text = @"待审核";
            self.stateLabel.textColor = NColorFrom16RGB(0xf97c14);
        }
            break;
        case 1:
        {
            self.stateLabel.text = @"等待受理";
             self.stateLabel.textColor = NColorFrom16RGB(0xf97c14);
        }
            break;
        case 2:
        {
            self.stateLabel.text = @"已受理";
            self.stateLabel.textColor = NColorFrom16RGB(0x5da7ff);
        }
            break;
        case 3:
        {
            self.stateLabel.text = @"已转交相关部门";
           self.stateLabel.textColor = NColorFrom16RGB(0x49cc93);
        }
            break;
        case 4:
        {
            self.stateLabel.text = @"自行解答";
           self.stateLabel.textColor = NColorFrom16RGB(0x49cc93);
        }
            break;
        case 5:
        {self.stateLabel.text = @"等待用户确认";
             self.stateLabel.textColor = NColorFrom16RGB(0xf97c14);
            
        }
            break;
        case 6:
        {
            self.stateLabel.text = @"等待用户评价";
             self.stateLabel.textColor = NColorFrom16RGB(0xf97c14);
        }
            break;
        case 7:
        {
           self.stateLabel.text = @"已评价";
            self.stateLabel.textColor = NColorFrom16RGB(0x5da7ff);
        }
            break;
        case 8:
        {
            self.stateLabel.text = @"已关闭";
           self.stateLabel.textColor = NColorFrom16RGB(0x666666);
        }
            break;
        case 9:
        {
            self.stateLabel.text = @"审核未通过";
            self.stateLabel.textColor = NColorFrom16RGB(0xeb2222);
        }
            break;
        case 10:
        {
            self.stateLabel.text = @"删除";
            self.stateLabel.textColor = NColorFrom16RGB(0xeb2222);
        }
            break;
            
        default:
            break;
    }
    
//    [self getProgressColorWithProgress:progress];
    
}

///问题类型
- (void)configCellWith:(NSString *)qType {
    if ([qType isEqualToString:@"1"]) {
        self.tipLabel.text = @"咨询";
    }else if ([qType isEqualToString:@"2"]){
        self.tipLabel.text = @"投诉";
    }else{
        self.tipLabel.text = @"建议";
    }
}


//时间戳转成时间
- (NSString *)timeTransfer:(NSString *)timeStampString {
    //    NSString *timeStampString  = @"1495453213000";
    // iOS
    NSTimeInterval interval =[timeStampString doubleValue]/1000.0;
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:interval];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm"];
    NSString *dateString = [formatter stringFromDate: date];
    return dateString;
    
}



- (void)awakeFromNib {
    [super awakeFromNib];
    self.selectionStyle = 0;
    
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
